{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 第一周作业"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 导入必要工具包 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 324,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np  # 矩阵操作\n",
    "import pandas as pd # SQL数据处理\n",
    "\n",
    "from sklearn.metrics import r2_score  #评价回归预测模型的性能\n",
    "\n",
    "import matplotlib.pyplot as plt   #画图\n",
    "import seaborn as sns\n",
    "\n",
    "# 图形出现在Notebook里而不是新窗口\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1、训练数据和测试数据分割（请将2012年的数据作为测试数据）"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1.1 读取数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 325,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>instant</th>\n",
       "      <th>dteday</th>\n",
       "      <th>season</th>\n",
       "      <th>yr</th>\n",
       "      <th>mnth</th>\n",
       "      <th>holiday</th>\n",
       "      <th>weekday</th>\n",
       "      <th>workingday</th>\n",
       "      <th>weathersit</th>\n",
       "      <th>temp</th>\n",
       "      <th>atemp</th>\n",
       "      <th>hum</th>\n",
       "      <th>windspeed</th>\n",
       "      <th>casual</th>\n",
       "      <th>registered</th>\n",
       "      <th>cnt</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>2011-01-01</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0.344167</td>\n",
       "      <td>0.363625</td>\n",
       "      <td>0.805833</td>\n",
       "      <td>0.160446</td>\n",
       "      <td>331</td>\n",
       "      <td>654</td>\n",
       "      <td>985</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>2011-01-02</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0.363478</td>\n",
       "      <td>0.353739</td>\n",
       "      <td>0.696087</td>\n",
       "      <td>0.248539</td>\n",
       "      <td>131</td>\n",
       "      <td>670</td>\n",
       "      <td>801</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>2011-01-03</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.196364</td>\n",
       "      <td>0.189405</td>\n",
       "      <td>0.437273</td>\n",
       "      <td>0.248309</td>\n",
       "      <td>120</td>\n",
       "      <td>1229</td>\n",
       "      <td>1349</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>2011-01-04</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.200000</td>\n",
       "      <td>0.212122</td>\n",
       "      <td>0.590435</td>\n",
       "      <td>0.160296</td>\n",
       "      <td>108</td>\n",
       "      <td>1454</td>\n",
       "      <td>1562</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>2011-01-05</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.226957</td>\n",
       "      <td>0.229270</td>\n",
       "      <td>0.436957</td>\n",
       "      <td>0.186900</td>\n",
       "      <td>82</td>\n",
       "      <td>1518</td>\n",
       "      <td>1600</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   instant      dteday  season  yr  mnth  holiday  weekday  workingday  \\\n",
       "0        1  2011-01-01       1   0     1        0        6           0   \n",
       "1        2  2011-01-02       1   0     1        0        0           0   \n",
       "2        3  2011-01-03       1   0     1        0        1           1   \n",
       "3        4  2011-01-04       1   0     1        0        2           1   \n",
       "4        5  2011-01-05       1   0     1        0        3           1   \n",
       "\n",
       "   weathersit      temp     atemp       hum  windspeed  casual  registered  \\\n",
       "0           2  0.344167  0.363625  0.805833   0.160446     331         654   \n",
       "1           2  0.363478  0.353739  0.696087   0.248539     131         670   \n",
       "2           1  0.196364  0.189405  0.437273   0.248309     120        1229   \n",
       "3           1  0.200000  0.212122  0.590435   0.160296     108        1454   \n",
       "4           1  0.226957  0.229270  0.436957   0.186900      82        1518   \n",
       "\n",
       "    cnt  \n",
       "0   985  \n",
       "1   801  \n",
       "2  1349  \n",
       "3  1562  \n",
       "4  1600  "
      ]
     },
     "execution_count": 325,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data = pd.read_csv(\"day.csv\")\n",
    "\n",
    "#通过观察前5行，了解数据每列（特征）的概况\n",
    "data.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1.2 数据基本信息"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 326,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(731, 16)"
      ]
     },
     "execution_count": 326,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 327,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 731 entries, 0 to 730\n",
      "Data columns (total 16 columns):\n",
      "instant       731 non-null int64\n",
      "dteday        731 non-null object\n",
      "season        731 non-null int64\n",
      "yr            731 non-null int64\n",
      "mnth          731 non-null int64\n",
      "holiday       731 non-null int64\n",
      "weekday       731 non-null int64\n",
      "workingday    731 non-null int64\n",
      "weathersit    731 non-null int64\n",
      "temp          731 non-null float64\n",
      "atemp         731 non-null float64\n",
      "hum           731 non-null float64\n",
      "windspeed     731 non-null float64\n",
      "casual        731 non-null int64\n",
      "registered    731 non-null int64\n",
      "cnt           731 non-null int64\n",
      "dtypes: float64(4), int64(11), object(1)\n",
      "memory usage: 91.5+ KB\n"
     ]
    }
   ],
   "source": [
    "data.info()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1.3 数据准备 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 328,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n"
     ]
    }
   ],
   "source": [
    "# 从原始数据中分离输入特征x和输出y\n",
    "y = data['cnt'].values\n",
    "X = data.drop(['casual','registered','cnt'], axis = 1)\n",
    "\n",
    "#用于后续显示权重系数对应的特征\n",
    "#columns = X.columns\n",
    "print(type(X))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 329,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(365, 13)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>instant</th>\n",
       "      <th>dteday</th>\n",
       "      <th>season</th>\n",
       "      <th>yr</th>\n",
       "      <th>mnth</th>\n",
       "      <th>holiday</th>\n",
       "      <th>weekday</th>\n",
       "      <th>workingday</th>\n",
       "      <th>weathersit</th>\n",
       "      <th>temp</th>\n",
       "      <th>atemp</th>\n",
       "      <th>hum</th>\n",
       "      <th>windspeed</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>360</th>\n",
       "      <td>361</td>\n",
       "      <td>2011-12-27</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>12</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>0.325000</td>\n",
       "      <td>0.327633</td>\n",
       "      <td>0.762500</td>\n",
       "      <td>0.188450</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>361</th>\n",
       "      <td>362</td>\n",
       "      <td>2011-12-28</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>12</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.299130</td>\n",
       "      <td>0.279974</td>\n",
       "      <td>0.503913</td>\n",
       "      <td>0.293961</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>362</th>\n",
       "      <td>363</td>\n",
       "      <td>2011-12-29</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>12</td>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.248333</td>\n",
       "      <td>0.263892</td>\n",
       "      <td>0.574167</td>\n",
       "      <td>0.119412</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>363</th>\n",
       "      <td>364</td>\n",
       "      <td>2011-12-30</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>12</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.311667</td>\n",
       "      <td>0.318812</td>\n",
       "      <td>0.636667</td>\n",
       "      <td>0.134337</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>364</th>\n",
       "      <td>365</td>\n",
       "      <td>2011-12-31</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>12</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.410000</td>\n",
       "      <td>0.414121</td>\n",
       "      <td>0.615833</td>\n",
       "      <td>0.220154</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     instant      dteday  season  yr  mnth  holiday  weekday  workingday  \\\n",
       "360      361  2011-12-27       1   0    12        0        2           1   \n",
       "361      362  2011-12-28       1   0    12        0        3           1   \n",
       "362      363  2011-12-29       1   0    12        0        4           1   \n",
       "363      364  2011-12-30       1   0    12        0        5           1   \n",
       "364      365  2011-12-31       1   0    12        0        6           0   \n",
       "\n",
       "     weathersit      temp     atemp       hum  windspeed  \n",
       "360           2  0.325000  0.327633  0.762500   0.188450  \n",
       "361           1  0.299130  0.279974  0.503913   0.293961  \n",
       "362           1  0.248333  0.263892  0.574167   0.119412  \n",
       "363           1  0.311667  0.318812  0.636667   0.134337  \n",
       "364           1  0.410000  0.414121  0.615833   0.220154  "
      ]
     },
     "execution_count": 329,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#将数据分割训练数据与测试数据\n",
    "from sklearn.model_selection import train_test_split\n",
    "\n",
    "# 随机采样20%的数据构建测试样本，其余作为训练样本\n",
    "#X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=33, test_size=0.5)\n",
    "X_train, X_test, y_train, y_test=X[:365],X[365:],y[:365],y[365:]\n",
    "print(X_train.shape)\n",
    "#print(X_test.shape)\n",
    "#X_test.head()\n",
    "X_train.tail()\n",
    "#X_train.info()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2、适当的特征工程（及数据探索） "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 2.1有些特征看起来是数据值特征，其实是类别型特征，如月份、季节 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 330,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 365 entries, 0 to 364\n",
      "Data columns (total 13 columns):\n",
      "instant       365 non-null int64\n",
      "dteday        365 non-null object\n",
      "season        365 non-null int64\n",
      "yr            365 non-null int64\n",
      "mnth          365 non-null int64\n",
      "holiday       365 non-null int64\n",
      "weekday       365 non-null int64\n",
      "workingday    365 non-null int64\n",
      "weathersit    365 non-null int64\n",
      "temp          365 non-null float64\n",
      "atemp         365 non-null float64\n",
      "hum           365 non-null float64\n",
      "windspeed     365 non-null float64\n",
      "dtypes: float64(4), int64(8), object(1)\n",
      "memory usage: 37.1+ KB\n"
     ]
    }
   ],
   "source": [
    "X_train.info()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 2.2 可以丢弃一些不必要的特征 "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### instant,dteday,yr本身与使用共享单车数目并没有直接关系"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 331,
   "metadata": {},
   "outputs": [],
   "source": [
    "X_train=X_train.drop(['instant','dteday','yr'], axis = 1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 332,
   "metadata": {},
   "outputs": [],
   "source": [
    "X_test=X_test.drop(['instant','dteday','yr'], axis = 1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### #holiday与workingday作用重复，season与mnth作用也类似"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 333,
   "metadata": {},
   "outputs": [],
   "source": [
    "X_train=X_train.drop(['season','holiday'], axis = 1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 334,
   "metadata": {},
   "outputs": [],
   "source": [
    "X_test=X_test.drop(['season','holiday'], axis = 1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 335,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(365, 8)"
      ]
     },
     "execution_count": 335,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X_train.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 336,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>temp</th>\n",
       "      <th>atemp</th>\n",
       "      <th>hum</th>\n",
       "      <th>windspeed</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.344167</td>\n",
       "      <td>0.363625</td>\n",
       "      <td>0.805833</td>\n",
       "      <td>0.160446</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.363478</td>\n",
       "      <td>0.353739</td>\n",
       "      <td>0.696087</td>\n",
       "      <td>0.248539</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.196364</td>\n",
       "      <td>0.189405</td>\n",
       "      <td>0.437273</td>\n",
       "      <td>0.248309</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.200000</td>\n",
       "      <td>0.212122</td>\n",
       "      <td>0.590435</td>\n",
       "      <td>0.160296</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.226957</td>\n",
       "      <td>0.229270</td>\n",
       "      <td>0.436957</td>\n",
       "      <td>0.186900</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       temp     atemp       hum  windspeed\n",
       "0  0.344167  0.363625  0.805833   0.160446\n",
       "1  0.363478  0.353739  0.696087   0.248539\n",
       "2  0.196364  0.189405  0.437273   0.248309\n",
       "3  0.200000  0.212122  0.590435   0.160296\n",
       "4  0.226957  0.229270  0.436957   0.186900"
      ]
     },
     "execution_count": 336,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Continuity_fields = ['temp','atemp', 'hum', 'windspeed']\n",
    "#分离离散值与连续值\n",
    "continuousTrainData_x = X_train.loc[:, Continuity_fields]\n",
    "continuousTestData_x = X_test.loc[:, Continuity_fields]\n",
    "distributiveTrainData_x = X_train.drop(['temp','atemp', 'hum', 'windspeed'],axis = 1)\n",
    "distributiveTestData_x = X_test.drop(['temp','atemp', 'hum', 'windspeed'],axis = 1)\n",
    "#distributiveTrainData_x.head()\n",
    "continuousTrainData_x.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 2.2 有些特征看起来是数据值特征，其实是类别型特征，如月份、季节"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 337,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn import preprocessing\n",
    "enc_train = preprocessing.OneHotEncoder()\n",
    "enc_test = preprocessing.OneHotEncoder() \n",
    "distributiveTrainData_x = enc_train.fit_transform(distributiveTrainData_x).toarray()\n",
    "distributiveTestData_x = enc_test.fit_transform(distributiveTestData_x).toarray()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 2.2 数值型特征归一化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 338,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "D:\\Anaconda3\\lib\\site-packages\\sklearn\\utils\\validation.py:475: DataConversionWarning: Data with input dtype int64 was converted to float64 by StandardScaler.\n",
      "  warnings.warn(msg, DataConversionWarning)\n"
     ]
    }
   ],
   "source": [
    "# 数据标准化\n",
    "from sklearn.preprocessing import StandardScaler\n",
    "\n",
    "# 分别初始化对特征和目标值的标准化器\n",
    "ss_X = StandardScaler()\n",
    "ss_y = StandardScaler()\n",
    "\n",
    "# 分别对训练和测试数据的特征以及目标值进行标准化处理\n",
    "continuousTrainData_x = ss_X.fit_transform(continuousTrainData_x)\n",
    "continuousTestData_x = ss_X.transform(continuousTestData_x)\n",
    "\n",
    "#组合特征值\n",
    "X_train = np.concatenate((distributiveTrainData_x,np.array(continuousTrainData_x)),axis=1)\n",
    "X_test = np.concatenate((distributiveTestData_x,np.array(continuousTestData_x)),axis=1)\n",
    "\n",
    "X_train=pd.DataFrame(X_train)\n",
    "X_test=pd.DataFrame(X_test)\n",
    "\n",
    "#对y做标准化不是必须\n",
    "#对y标准化的好处是不同问题的w差异不太大，同时正则参数的范围也有限\n",
    "y_train = ss_y.fit_transform(y_train.reshape(-1, 1))\n",
    "y_test = ss_y.transform(y_test.reshape(-1, 1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 339,
   "metadata": {},
   "outputs": [],
   "source": [
    "colums=range(X_train.shape[1])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 3、岭回归，并选择最佳的正则参数 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 340,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>coef</th>\n",
       "      <th>columns</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>[1607443908474.2002]</td>\n",
       "      <td>20</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>[1607443908473.824]</td>\n",
       "      <td>19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>[0.583740234375]</td>\n",
       "      <td>24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>[-0.1298828125]</td>\n",
       "      <td>27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>[-0.1475830078125]</td>\n",
       "      <td>26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>[-0.1669921875]</td>\n",
       "      <td>25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>[-2951536376906.9746]</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>[-2951536376907.002]</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>[-2951536376907.0605]</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>[-2951536376907.1523]</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>[-2951536376907.293]</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>[-2951536376907.3867]</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>[-2951536376907.491]</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>[-2951536376907.543]</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>[-2951536376907.6406]</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>[-2951536376908.164]</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>[-2951536376908.392]</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>[-2951536376908.5474]</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>[-11159910978512.24]</td>\n",
       "      <td>18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>[-11159910978512.305]</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>[-11159910978512.605]</td>\n",
       "      <td>17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>[-11159910978512.623]</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>[-11159910978512.627]</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>[-11159910978512.639]</td>\n",
       "      <td>15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>[-11159910978512.662]</td>\n",
       "      <td>16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>[-17398699025110.596]</td>\n",
       "      <td>21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>[-17398699025110.793]</td>\n",
       "      <td>22</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>[-17398699025111.723]</td>\n",
       "      <td>23</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     coef  columns\n",
       "20   [1607443908474.2002]       20\n",
       "19    [1607443908473.824]       19\n",
       "24       [0.583740234375]       24\n",
       "27        [-0.1298828125]       27\n",
       "26     [-0.1475830078125]       26\n",
       "25        [-0.1669921875]       25\n",
       "9   [-2951536376906.9746]        9\n",
       "4    [-2951536376907.002]        4\n",
       "8   [-2951536376907.0605]        8\n",
       "5   [-2951536376907.1523]        5\n",
       "10   [-2951536376907.293]       10\n",
       "7   [-2951536376907.3867]        7\n",
       "6    [-2951536376907.491]        6\n",
       "3    [-2951536376907.543]        3\n",
       "11  [-2951536376907.6406]       11\n",
       "2    [-2951536376908.164]        2\n",
       "1    [-2951536376908.392]        1\n",
       "0   [-2951536376908.5474]        0\n",
       "18   [-11159910978512.24]       18\n",
       "12  [-11159910978512.305]       12\n",
       "17  [-11159910978512.605]       17\n",
       "14  [-11159910978512.623]       14\n",
       "13  [-11159910978512.627]       13\n",
       "15  [-11159910978512.639]       15\n",
       "16  [-11159910978512.662]       16\n",
       "21  [-17398699025110.596]       21\n",
       "22  [-17398699025110.793]       22\n",
       "23  [-17398699025111.723]       23"
      ]
     },
     "execution_count": 340,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 线性回归\n",
    "#class sklearn.linear_model.LinearRegression(fit_intercept=True, normalize=False, copy_X=True, n_jobs=1)\n",
    "from sklearn.linear_model import LinearRegression\n",
    "\n",
    "# 使用默认配置初始化\n",
    "lr = LinearRegression()\n",
    "\n",
    "# 训练模型参数\n",
    "lr.fit(X_train, y_train)\n",
    "\n",
    "# 预测\n",
    "y_test_pred_lr = lr.predict(X_test)\n",
    "y_train_pred_lr = lr.predict(X_train)\n",
    "\n",
    "\n",
    "# 看看各特征的权重系数，系数的绝对值大小可视为该特征的重要性\n",
    "fs = pd.DataFrame({\"columns\":list(range(X_train.shape[1])), \"coef\":list((lr.coef_.T))})\n",
    "fs.sort_values(by=['coef'],ascending=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 341,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAekAAAFsCAYAAADos0H8AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAHmxJREFUeJzt3XuUnXV97/H3lzAmlkAwMIGQSBMQVK4THCIpBaPxggYJntqiB7ksAlGULqrVKnosI9W2LqkcOSKr8QYISoDWQr2cwomkEY5CExohGDQR4ZiQJiHKJSiXJN/zx34mbpKZzM7MnplfZr9fa+2193PZz/P97WdmPvN7bjsyE0mSVJ49hrsASZLUM0NakqRCGdKSJBXKkJYkqVCGtCRJhTKkJUkqlCGtlhcRD0bEzOGuYzhFxDsi4lcRsSkipg3hejdFxCG9TDs3Iu5q0noeiYg3NmNZ0lAypDWi9fTH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rrvuOq688sp+rX842JOWJAHw0pe+lGXLlrF8+XLGjx/PVVdd1a/lfOUrX9khoEvQ2dk56AG9ZcuWpi7PkJYk7WDGjBmsWbNm2/DnPvc5jj/+eI455hguvfRSAJ555hlmz57Nsccey1FHHcWCBQuAWi+2+xbQX//61zn88MN53etex913371teeeeey633HLLtuGxY8cCsGnTJmbNmsVxxx3H0Ucfza233rpDbWvXruXkk0+mo6ODo446ih/+8IcNtWnRokWceuqpAHR1dXHeeecxc+ZMDjnkkBeF9/XXX8/06dPp6Ojgve9977bgvfDCC+ns7OTII4/c9hlA7ZbXl112GX/8x3/MzTff3FAtjXJ3tyTpRbZs2cLChQuZO3cuALfffjsrV67k3nvvJTM57bTTWLx4MRs2bOCggw7iu9/9LgBPPvnki5azdu1aLr30UpYuXcq4ceN4/etfz7Rp03a67jFjxvDtb3+bffbZh8cff5wTTjiB00477UUnYH3zm9/kLW95C5/4xCfYsmULv/3tb/vVzoceeog777yTp59+mle+8pVceOGFrFq1igULFnD33XfT1tbG+9//fm644QbOPvtsPvOZzzB+/Hi2bNnCrFmzuP/++znmmGO21X3XXXf1q46dMaQlSQD87ne/o6Ojg0ceeYTXvOY1vOlNbwJqIX377bdvC9hNmzaxcuVKTjrpJD784Q/z0Y9+lFNPPZWTTjrpRcu75557mDlzJu3ttS97OuOMM/j5z3++0xoyk49//OMsXryYPfbYgzVr1rBu3ToOPPDAbfMcf/zxnHfeebzwwgucfvrpdHR09Ku9s2fPZvTo0YwePZoJEyawbt06Fi5cyNKlSzn++OO3fSYTJkwA4KabbmL+/Pls3ryZtWvX8tOf/nRbSJ9xxhn9qqEv7u6WJAG/Pyb96KOP8vzzz287Jp2ZXHLJJSxbtoxly5axatUq5s6dy+GHH87SpUs5+uijueSSS7jssst2WGZvlyDtueeebN26ddvyn3/+eQBuuOEGNmzYwNKlS1m2bBkHHHDADtcZn3zyySxevJhJkyZx1llncd111/WrvaNHj972etSoUWzevJnM5JxzztnW1p/97Gd0dXXxy1/+kssvv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rPt2x2HPQ1YMYT1DafbgLOrs7xPAJ7sPgw00kXEgd3nXETEdGr5uHHn7xoCmemj7gG8g9p/k88B64B/q8YfBHyven0I8JPq8SC1XcXDXvtQtL0afhvwc2o9yJHS9v2ondW9snoeX43vBL5Svf4j4IFquz8AzB3uugfY5h22I3AZcFr1egxwM7AKuBc4ZLhrHsK2/131u/0T4E7gVcNdc5Pa/S1gLfBC9bs+F3gf8L5qelA78/0X1c9453DXPIRtv6hum/8Y+KPhrjkzvS2oJEmlcne3JEmFMqQlSSqUIS1JUqEMaUmSCmVIS5JUKENakqRCGdKSJBXq/wMEdXM1ofzBoQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x233591cee10>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#在训练集上观察预测残差的分布，看是否符合模型假设：噪声为0均值的高斯噪声\n",
    "f, ax = plt.subplots(figsize=(7, 5)) \n",
    "f.tight_layout() \n",
    "ax.hist(y_train - y_train_pred_lr,bins=40, label='Residuals Linear', color='b', alpha=.5); \n",
    "ax.set_title(\"Histogram of Residuals\") \n",
    "ax.legend(loc='best');"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 342,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The r2 score of RidgeCV on test is -0.6762650448561494\n",
      "The r2 score of RidgeCV on train is 0.8222060130522983\n"
     ]
    }
   ],
   "source": [
    "#岭回归／L2正则\n",
    "#class sklearn.linear_model.RidgeCV(alphas=(0.1, 1.0, 10.0), fit_intercept=True, \n",
    "#                                  normalize=False, scoring=None, cv=None, gcv_mode=None, \n",
    "#                                  store_cv_values=False)\n",
    "from sklearn.linear_model import  RidgeCV\n",
    "\n",
    "#设置超参数（正则参数）范围\n",
    "alphas = [ 0.01, 0.1, 1, 10,100]\n",
    "#n_alphas = 20\n",
    "#alphas = np.logspace(-5,2,n_alphas)\n",
    "\n",
    "#生成一个RidgeCV实例\n",
    "ridge = RidgeCV(alphas=alphas, store_cv_values=True)  \n",
    "\n",
    "#模型训练\n",
    "ridge.fit(X_train, y_train)    \n",
    "\n",
    "#预测\n",
    "y_test_pred_ridge = ridge.predict(X_test)\n",
    "y_train_pred_ridge = ridge.predict(X_train)\n",
    "\n",
    "\n",
    "# 评估，使用r2_score评价模型在测试集和训练集上的性能\n",
    "print('The r2 score of RidgeCV on test is', (r2_score(y_test, y_test_pred_ridge)))\n",
    "print('The r2 score of RidgeCV on train is', (r2_score(y_train, y_train_pred_ridge)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 343,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAARgAAADQCAYAAADcQn7hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJztnXl4lPW1+D8nYZREhYBQlcgmWkBFQSKi0FqVFqkKAb2lFLRyL1qvXiwuqFhbsPVXQStW621dqtRbrYLFBhQVQakoFSWyCMhSFVkCrSAJa4As5/fHzMTJZJZ3lnfeSXI+z5Mnme37nsnMe97zPauoKoZhGG6Q47UAhmE0XUzBGIbhGqZgDMNwDVMwhmG4hikYwzBcwxSMYRiuYQrGMAzXMAVjGIZrmIIxDMM1WngtQCK0a9dOu3Tp4rUYhtHs+eijj3apavt4z2tUCqZLly6UlpZ6LYZhNHtEZLOT59kWyTAM1zAFYxiGa3imYESkpYh8KCKrRGStiNzrlSyGYbiDlz6Yw8DFqrpfRHzAeyLyuqou9VAmwzDSiGcWjPrZH7jpC/xYcxrDCGH//v18/vnnXouRNJ76YEQkV0RWAl8CC1T1gwjPuV5ESkWkdOfOnZkX0jA8ZMaMGQwZMoSqqiqvRUkKyYaOdiJSAPwNGK+qa6I9r6ioSC1MbTQH9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SjcBJ/b/APPxOzxnNVXlEmAAcDVwceAzXRm4uhtxMAvGMAzXMAvGMAzXMAVjGIZrmIIxDMM1TMEYhuEapmAMw3ANS7Qz6hCR44G3AjdPBGqAYC5Pv0DdUaZlmg9cFagBMhoZFqY2IiIiU4D9qvqbsPsF//cmpRoVB8fPyHEMd7EtkhEXETlVRNYEkgaXAx1FpCLk8R+KyB8Df58gIi+LSKmIfCgi/SOsNy7QK2d+oKfMPVGOc5KIbAv21BGRsYE+O6tEZIbT4xneYVskwymnA2NV9YZAqUA0HgUeUNWlgcrjV4EzIzyvX+D+I8CyQFOj/aHHAfAbMiAiZwN3Aheo6m4RaZvg8QwPMAVjOOUzVV3m4HmDgO5BxQC0EZE8Va0Me958VS0HEJESYCDwRozjXAzMVNXdAMHfCRzP8ABTMIZTDoT8XUv9lg0tQ/4WnDmEw51/wdsHwp8Ysm4kh6HT4xkeYD4YI2ECjtdyETlNRHKA4SEPLwRuCt4Qkd5RlvmeiBSISD7+bnhL4hx2IfDD4NYoZIvk9HiGB5iCMZLlTvxbmrfw94cJchMwIOCM/QS4Lsrr3wP+AqwAXlDVlbEOpqofAw8Ai0VkJfBggsczPMDC1EbGEZFx+BujN6veKs0Rs2AMw3ANs2AMw3ANs2AMw3ANUzCGYbiGKRjDMFzDFIxhGK5hCsYwDNf4/1w1gPhWxpsbAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x23359106e80>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#观察预测值与真值的散点图\n",
    "plt.figure(figsize=(4, 3))\n",
    "plt.scatter(y_test, y_test_pred_ridge)\n",
    "plt.plot([-3, 3], [-3, 3], '--k')   #数据已经标准化，3倍标准差即可\n",
    "plt.axis('tight')\n",
    "plt.xlabel('True price')\n",
    "plt.ylabel('Predicted price')\n",
    "plt.tight_layout()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 3.2 可视化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 344,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYsAAAEKCAYAAADjDHn2AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzt3XmUVPWd9/H3tzf2nRaQrQFRQdxblN0xmkEzkcQkbnFfmYzPM/PkmZk4j3PMmcyZMzM6M895ZsYZwYhLYtyjIUZjjFEQFKQRXEBR6G7oZl9kh16qvs8fdVvKtouqhr51q6o/r3P6dNW9v1v3W5emP32X+l5zd0RERI6mKOoCREQk9yksREQkLYWFiIikpbAQEZG0FBYiIpKWwkJERNJSWIiISFoKCxERSUthISIiaZVEXUBHGThwoFdUVERdhohIXlm+fPkOdy9PN65gwqKiooKqqqqoyxARyStmtj6TcToMJSIiaSksREQkLYWFiIikpbAQEZG0FBYiIpKWwkJERNJSWIiISFoKCxGRPPbCinqeW15P2LfIVliIiOSpxuY4//TKJ/zyvXrMLNR1KSxERPLUiys3snVvA3fOGBP6uhQWIiJ5KB535i6sZtyQ3kwfOzD09SksRETy0OufbGPttv3MnjE69ENQoLAQEclLcxasY2jfbnzj9CFZWZ/CQkQkz1TV7qJq/efcPm0UJcXZ+TWusBARyTMPLqimX/dSrjxveNbWqbAQEckja7ft4/cfb+WGSRV0L8veLYkUFiIieWTOgmq6lhZx4+SKrK5XYSEikie27DnMiys3clXlcPr3KMvquhUWIiJ5Yt7iGuIOt00bnfV1KyxERPLAnkNN/GLpBr5x+hCG9++e9fUrLERE8sATS9ezv6GZO6Znf68CFBYiIjnvcFOMRxbXMm3sQCYM7RNJDQoLEZEc9+KKjWzf18DsLDQMTEVhISKSw2JBw8AJQ3szecyAyOpQWIiI5LDXVm+lescBZs8Yk5WGgakoLEREcpS78+C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SJq+DbgkGH8V8O9J46uAae1/qyLtU9CNBEXaaSqJzqsxYKuZLQDOC6Y/6+5xYIuZvZG0zBBge9LzK4OW8SXBvPEk2jMkiwNPB49/DiQ3hGt5vJxEQAGUAv9pZmcBMeDkpPHbSLRcEQmVwkLkiFQ3ITrazYkOkej3hJmNAv4SOM/dPzezR1vmpZHcc6ch+B7jyP/P/0WiH9eZJI4GHE4a3zWoQSRUOgwlcsRC4CozKw7OI0wn0exvEYkbAxWZ2SASt9Vs8TFwUvC4N3AA2BOMuzTFeopIdJwFuDZ4/aPpA2wO9myuJ3Gb1BYnkxsdh6XAac9C5IgXSJyPeJ/EX/t/7e5bzOx54Gskfil/SuLuZHuCZX5DIjx+7+7vm9kKEh1Jq4HFKdZzADjNzJYHr3NVmrr+C3jezL5HoiPsgaR5fxTUIBIqdZ0VyYCZ9fTEndEGkNjbmBIESTcSv8CnBOc6Mnmt/e7es4PqWgjMcvfPO+L1RFLRnoVIZl4ys75AGfD37r4FwN0PmdmPSdzneEM2CwoOlf2bgkKyQXsWIiKSlk5wi4hIWgoLERFJS2EhIiJpKSxERCQthYWIiKSlsBARkbT+PzRJu/rpqC5MAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x23358f1dcc0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "alpha is: 1.0\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>coef_lr</th>\n",
       "      <th>coef_ridge</th>\n",
       "      <th>columns</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>[1607443908474.2002]</td>\n",
       "      <td>[0.14879929630391564]</td>\n",
       "      <td>20</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>[1607443908473.824]</td>\n",
       "      <td>[-0.14879929630391275]</td>\n",
       "      <td>19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>[0.583740234375]</td>\n",
       "      <td>[0.4465589474930137]</td>\n",
       "      <td>24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>[-0.1298828125]</td>\n",
       "      <td>[-0.1316735240402745]</td>\n",
       "      <td>27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>[-0.1475830078125]</td>\n",
       "      <td>[-0.1480803984324322]</td>\n",
       "      <td>26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>[-0.1669921875]</td>\n",
       "      <td>[0.029002243949391965]</td>\n",
       "      <td>25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>[-2951536376906.9746]</td>\n",
       "      <td>[0.5405437508370186]</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>[-2951536376907.002]</td>\n",
       "      <td>[0.48799560962999095]</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>[-2951536376907.0605]</td>\n",
       "      <td>[0.45741743996601597]</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>[-2951536376907.1523]</td>\n",
       "      <td>[0.34425680062324465]</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>[-2951536376907.293]</td>\n",
       "      <td>[0.27113993491859273]</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>[-2951536376907.3867]</td>\n",
       "      <td>[0.09528884692115817]</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>[-2951536376907.491]</td>\n",
       "      <td>[-0.010332991168896355]</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>[-2951536376907.543]</td>\n",
       "      <td>[0.001465149725495822]</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>[-2951536376907.6406]</td>\n",
       "      <td>[-0.03784187769581854]</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>[-2951536376908.164]</td>\n",
       "      <td>[-0.5408925374754288]</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>[-2951536376908.392]</td>\n",
       "      <td>[-0.7440003973556821]</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>[-2951536376908.5474]</td>\n",
       "      <td>[-0.8650397289256893]</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>[-11159910978512.24]</td>\n",
       "      <td>[0.23480992782501636]</td>\n",
       "      <td>18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>[-11159910978512.305]</td>\n",
       "      <td>[0.14390274776094955]</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>[-11159910978512.605]</td>\n",
       "      <td>[-0.05001887570951939]</td>\n",
       "      <td>17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>[-11159910978512.623]</td>\n",
       "      <td>[-0.05000636659191947]</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>[-11159910978512.627]</td>\n",
       "      <td>[-0.07469735734465875]</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>[-11159910978512.639]</td>\n",
       "      <td>[-0.10030947860620458]</td>\n",
       "      <td>15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>[-11159910978512.662]</td>\n",
       "      <td>[-0.10368059733366085]</td>\n",
       "      <td>16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>[-17398699025110.596]</td>\n",
       "      <td>[0.4125975281285337]</td>\n",
       "      <td>21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>[-17398699025110.793]</td>\n",
       "      <td>[0.2252327872696695]</td>\n",
       "      <td>22</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>[-17398699025111.723]</td>\n",
       "      <td>[-0.6378303153982041]</td>\n",
       "      <td>23</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                  coef_lr               coef_ridge  columns\n",
       "20   [1607443908474.2002]    [0.14879929630391564]       20\n",
       "19    [1607443908473.824]   [-0.14879929630391275]       19\n",
       "24       [0.583740234375]     [0.4465589474930137]       24\n",
       "27        [-0.1298828125]    [-0.1316735240402745]       27\n",
       "26     [-0.1475830078125]    [-0.1480803984324322]       26\n",
       "25        [-0.1669921875]   [0.029002243949391965]       25\n",
       "9   [-2951536376906.9746]     [0.5405437508370186]        9\n",
       "4    [-2951536376907.002]    [0.48799560962999095]        4\n",
       "8   [-2951536376907.0605]    [0.45741743996601597]        8\n",
       "5   [-2951536376907.1523]    [0.34425680062324465]        5\n",
       "10   [-2951536376907.293]    [0.27113993491859273]       10\n",
       "7   [-2951536376907.3867]    [0.09528884692115817]        7\n",
       "6    [-2951536376907.491]  [-0.010332991168896355]        6\n",
       "3    [-2951536376907.543]   [0.001465149725495822]        3\n",
       "11  [-2951536376907.6406]   [-0.03784187769581854]       11\n",
       "2    [-2951536376908.164]    [-0.5408925374754288]        2\n",
       "1    [-2951536376908.392]    [-0.7440003973556821]        1\n",
       "0   [-2951536376908.5474]    [-0.8650397289256893]        0\n",
       "18   [-11159910978512.24]    [0.23480992782501636]       18\n",
       "12  [-11159910978512.305]    [0.14390274776094955]       12\n",
       "17  [-11159910978512.605]   [-0.05001887570951939]       17\n",
       "14  [-11159910978512.623]   [-0.05000636659191947]       14\n",
       "13  [-11159910978512.627]   [-0.07469735734465875]       13\n",
       "15  [-11159910978512.639]   [-0.10030947860620458]       15\n",
       "16  [-11159910978512.662]   [-0.10368059733366085]       16\n",
       "21  [-17398699025110.596]     [0.4125975281285337]       21\n",
       "22  [-17398699025110.793]     [0.2252327872696695]       22\n",
       "23  [-17398699025111.723]    [-0.6378303153982041]       23"
      ]
     },
     "execution_count": 344,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mse_mean = np.mean(ridge.cv_values_, axis = 0)\n",
    "plt.plot(np.log10(alphas), mse_mean.reshape(len(alphas),1)) \n",
    "\n",
    "#这是为了标出最佳参数的位置，不是必须\n",
    "#plt.plot(np.log10(ridge.alpha_)*np.ones(3), [0.28, 0.29, 0.30])\n",
    "\n",
    "plt.xlabel('log(alpha)')\n",
    "plt.ylabel('mse')\n",
    "plt.show()\n",
    "\n",
    "print ('alpha is:', ridge.alpha_)\n",
    "\n",
    "# 看看各特征的权重系数，系数的绝对值大小可视为该特征的重要性\n",
    "fs = pd.DataFrame({\"columns\":list(range(X_train.shape[1])),\"coef_lr\":list((lr.coef_.T)), \"coef_ridge\":list((ridge.coef_.T))})\n",
    "fs.sort_values(by=['coef_lr'],ascending=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 4、Lasso，并选择最佳的正则参数 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 345,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The r2 score of LassoCV on test is -0.8464904044420005\n",
      "The r2 score of LassoCV on train is 0.6477509138640337\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "D:\\Anaconda3\\lib\\site-packages\\sklearn\\linear_model\\coordinate_descent.py:1094: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().\n",
      "  y = column_or_1d(y, warn=True)\n"
     ]
    }
   ],
   "source": [
    "#### Lasso／L1正则\n",
    "# class sklearn.linear_model.LassoCV(eps=0.001, n_alphas=100, alphas=None, fit_intercept=True, \n",
    "#                                    normalize=False, precompute=’auto’, max_iter=1000, \n",
    "#                                    tol=0.0001, copy_X=True, cv=None, verbose=False, n_jobs=1,\n",
    "#                                    positive=False, random_state=None, selection=’cyclic’)\n",
    "from sklearn.linear_model import LassoCV\n",
    "\n",
    "#设置超参数搜索范围\n",
    "#alphas = [ 0.01, 0.1, 1, 10,100]\n",
    "\n",
    "#生成一个LassoCV实例\n",
    "#lasso = LassoCV(alphas=alphas)  \n",
    "lasso = LassoCV()  \n",
    "\n",
    "#训练（内含CV）\n",
    "lasso.fit(X_train, y_train)  \n",
    "\n",
    "#测试\n",
    "y_test_pred_lasso = lasso.predict(X_test)\n",
    "y_train_pred_lasso = lasso.predict(X_train)\n",
    "\n",
    "\n",
    "# 评估，使用r2_score评价模型在测试集和训练集上的性能\n",
    "print('The r2 score of LassoCV on test is', r2_score(y_test, y_test_pred_lasso))\n",
    "print('The r2 score of LassoCV on train is', r2_score(y_train, y_train_pred_lasso))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 346,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAARgAAADQCAYAAADcQn7hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJztnXt4VOW1/z8ryUASbgFBLVEEURErCoUigkpVKuKNiLbWiqKnaKserVVRUFuh1QpSrcfSX622Uql6Ki02iNQqKJSKogQCCHI5gHIJVkEI1yHX9ftjZuIkzGVPZvbsSbI+z5MnmZm997smyf7Oete73rVEVTEMw3CDLK8NMAyj+WICYxiGa5jAGIbhGiYwhmG4hgmMYRiuYQJjGIZrmMAYhuEaJjCGYbiGCYxhGK6R47UBidC5c2ft3r2712YYRotn2bJlu1S1S7zjmpTAdO/enZKSEq/NMIwWj4hscXKcTZEMw3ANExjDMFzDM4ERkVwR+VBEVorIGhGZ5JUthmG4g5cxmArgAlU9ICI+4F0ReUNVl3hok2EYKcQzD0YDHAg+9AW/rDiNYYRx4MABNm/e7LUZjcbTGIyIZIvICuALYJ6qfhDhmFtEpERESnbu3Jl+Iw3DQ6ZPn86IESOoqqry2pRGIZlQ0U5ECoC/A3eo6upoxw0YMEBtmdpoCRw4cIC2bdtSW1vL8uXLGTBggNcm1UNElqlqXKMyYhVJVcuBhcDFHptiGJ6iqjzxxBOccsopbNu2jaysrIwTl0TwchWpS9BzQUTygGHAOq/sMQyv8fv9XH/99dx7770MHjyYjh07em1S0ni5ivQ14AURySYgdDNV9XUP7TEMz9i6dStXXnklpaWlPPLIIzzwwAOIiNdmJY1nAqOqq4B+Xo1vGJnExIkT2bhxI6+99hqXXXaZ1+akjIwI8jrFgrxGc0JVOXDgAO3atWPfvn189tln9OrVy2uz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CTToM12FhuZhpPNjkaKeOeddxgwYABbtmzhhRdeOGKVKNl+xW41jjOMxmICkwZUlaeeeoqLLrqIY445hg8//JCLL774iONiJd45wXYWG5mGTZHSxHvvvcfll1/OjBkzaNfuyGLckJosYatBa2QSJjAusn37dqqqqujRowczZsygVatWZGVFdxothmI0N2yK5BLvvvsu/fv3Z/To0agqubm5McUFLIZiND88ERgRmSoi60RklYj8XUQKvLDDLZ555hnOP/98OnTowHPPPee4e4LFUIzmhid5MCJyEfBOMEN4CoCq3h/vvEzPg6moqODOO+/k2WefZcSIEbz88ssUFDQr7TQMIEVQWJjPAAAH2ElEQVQV7dxCVd8K25m9hEBZziZPTU0NS5cu5YEHHmDOnDkmLkaLJxOCvP8FvBLtRRG5BbgFoFu3bumyKSGWLVvGKaecQrt27XjvvffIzc312iTDyAhc82BEZL6IrI7wNTLsmAeBauClaNdR1WdVdYCqDujSpYtb5jaaP/3pTwwePJgJEyYAmLgYRhiueTDx+iKJyBjgMuBCbUobooJUVVVx77338vTTT3PhhRcyadIkr00yjIzDkymSiFwM3A8MVdVDXtiQDDt37uS73/0uCxcu5O6772bKlCnk5GTCbNMwMguv7oppQGtgXnAJd4mq/sgjWxLG7/ezefNm/vznPzN69GivzTGMjMUTgVHVk7wYN1kWLFjA0KFD6datGxs2bKB169Zem2QYGY1l8jqgpqaG++67jwsuuIDnn38ewMTFMBxggYM47N69m2uvvZa33nqL2267jRtuuMFrkwyjyWACE4PVq1dTVFTE1q1bee655xg7dqzXJhlGk8IEJgbl5eVUVVXxr3/9i7PPPttrcwyjyWExmAbU1tby9ttvA3DOOeewYcMGExfDaCQmMGHs3buXkSNHMmzYMJYuXQpYMNcwksGmSEHWr1/PyJEj2bRpE9OmTWPAgLgbRQ3DiIMJDDB37ly+//3v06pVK+bPn8/QoUO9NskwmgUmMMCOHTvo2bMnxcXFGbtj2zCaIi02BnPgwAH+/e9/A3DzzTezZMkSExfDSDEtUmA2bdrE2WefzaWXXsru3bsBaNWqlcdWGUb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kRdVdXSiF7JEuxQjIhcDTwJDVXWn1/a4gYjkEAhgXwiUAUuB76vqGk8NcwkJdOt7Aditqnd5bU86CXow96rqZY0532IwqWca0A6YF+xc+YzXBqWaYBD7v4E3CQQ8ZzZXcQkyBLgeuCD4N10R/HQ34mAejGEYrmEejGEYrmECYxiGa5jAGIbhGiYwhmG4hgmMYRiuYYl2Rh0ichTwdvDhsUANEMrlGRjcd5Rum94Erg7uATKaGLZMbURERCYCB1T1Vw2eFwL/N0ntUXEwflrGMdzFpkhGXETkJBFZHUwaXA4cLyLlYa9/T0T+EPz5GBF5VURKRORDERkU4Xpjg7Vy3gzWlHkoyjhfE5HtoZo6InJTsM7OShGZ7nQ8wztsimQ45TTgJlX9UXCrQDSeBh5X1SXBncevA6dHOG5g8PlKYGmwqNGB8HEAAo4MiMiZwP3AYFXdLSKdEhzP8AATGMMpm1R1qYPjhgG9QsIAdBSRPFX1NzjuTVXdAyAixcA5wD9jjHMB8Iqq7gYIfU9gPMMDTGAMpxwM+7mW+iUbcsN+FpwFhBsG/0KPDzY8MOy6kQKGTsczPMBiMEbCBAOve0TkZBHJAq4Me3k+cHvogYj0jXKZi0SkQETyCVTDWxxn2PnA90JTo7ApktPxDA8wgTEay/0EpjRvE6gPE+J2YEgwGPsxcHOU898FXgZKgf9V1RWxBlPVVcDjwCIRWQFMTXA8wwNsmdpIOyIylkBh9BZVW6UlYh6MYRiuYR6MYRiuYR6MYRiuYQJjGIZrmMAYhuEaJjCGYbiGCYxhGK7x/wGKJNGkj3Ah/QAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x23358f58fd0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#观察预测值与真值的散点图\n",
    "plt.figure(figsize=(4, 3))\n",
    "plt.scatter(y_test, y_test_pred_lasso)\n",
    "plt.plot([-3, 3], [-3, 3], '--k')   #数据已经标准化，3倍标准差即可\n",
    "plt.axis('tight')\n",
    "plt.xlabel('True price')\n",
    "plt.ylabel('Predicted price')\n",
    "plt.tight_layout()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 347,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYYAAAEKCAYAAAAW8vJGAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzt3Xd8XNWd9/HPT92S1SzJsi3ZyDYuuAKWC6YZCGBINoSOKSEEAiSEJJuHTbKbPGF382TzZNnklewuJSYBh6WFEkoIPQFMcUHGxhXcbcmyJVm9WG3m7B8zdiQjySNLo6sZfd+vl16acubO7+pK+s49595zzTmHiIjIYTFeFyAiIoOLgkFERDpRMIiISCcKBhER6UTBICIinSgYRESkEwWDiIh0omAQEZFOFAwiItJJnNcF9FZ2drYrKCjwugwRkYiyZs2ag865nFDaRlwwFBQUUFRU5HUZIiIRxcz2hNpWXUkiItKJgkFERDpRMIiISCcKBhER6UTBICIinSgYRESkEwWDiIh0EnHnMYiIDBX1zW3srWpi98Emdlc2Mis/nTMnhXSOWp8oGEREBkBVYyu/e28nbT6HBR9r9zvafH5a2/00tLTT0NJO3aE2KhtbqahvoanV12kZt589UcEgIhItfvXmVh5ZsYek+BicCzwWHxtDfKwRHxvD8MQ4UpPiGJ4Ux+zMDEamJpKTmsjYEckUZKVwQlYyKYkD8y9bwSAiEmb7aw/x5Opilswbx88um+l1OcekwWcRkTC7/+0d+J3jjnMmel1KSBQMIiJhdHhv4crCseRnJntdTkgUDCIiYRRpewugYBARCZtI3FsABYOISNi8uK6UVp+fbyyKnL0FUDCIiITNhn215GcOY+yIyNlbAAWDiEjYbCqtY8aYdK/L6DUFg4hIGNQ1t7HrYCMz8tK8LqXXwhYMZvaQmZWb2cYe2iwys3VmtsnM3glXLS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iIh0omAQEZFOFAwiItKJgkFERDr5X6MIRzvDPPu1AAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x23356462780>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "alpha is: 0.06288646311386441\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>coef_lasso</th>\n",
       "      <th>coef_lr</th>\n",
       "      <th>coef_ridge</th>\n",
       "      <th>columns</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>-0.000000</td>\n",
       "      <td>[1607443908474.2002]</td>\n",
       "      <td>[0.14879929630391564]</td>\n",
       "      <td>20</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>[1607443908473.824]</td>\n",
       "      <td>[-0.14879929630391275]</td>\n",
       "      <td>19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>0.144632</td>\n",
       "      <td>[0.583740234375]</td>\n",
       "      <td>[0.4465589474930137]</td>\n",
       "      <td>24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>-0.130831</td>\n",
       "      <td>[-0.1298828125]</td>\n",
       "      <td>[-0.1316735240402745]</td>\n",
       "      <td>27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>-0.051002</td>\n",
       "      <td>[-0.1475830078125]</td>\n",
       "      <td>[-0.1480803984324322]</td>\n",
       "      <td>26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>0.555132</td>\n",
       "      <td>[-0.1669921875]</td>\n",
       "      <td>[0.029002243949391965]</td>\n",
       "      <td>25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>[-2951536376906.9746]</td>\n",
       "      <td>[0.5405437508370186]</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>[-2951536376907.002]</td>\n",
       "      <td>[0.48799560962999095]</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>[-2951536376907.0605]</td>\n",
       "      <td>[0.45741743996601597]</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>[-2951536376907.1523]</td>\n",
       "      <td>[0.34425680062324465]</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>[-2951536376907.293]</td>\n",
       "      <td>[0.27113993491859273]</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>-0.000000</td>\n",
       "      <td>[-2951536376907.3867]</td>\n",
       "      <td>[0.09528884692115817]</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>-0.000000</td>\n",
       "      <td>[-2951536376907.491]</td>\n",
       "      <td>[-0.010332991168896355]</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>-0.000000</td>\n",
       "      <td>[-2951536376907.543]</td>\n",
       "      <td>[0.001465149725495822]</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>[-2951536376907.6406]</td>\n",
       "      <td>[-0.03784187769581854]</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>-0.000000</td>\n",
       "      <td>[-2951536376908.164]</td>\n",
       "      <td>[-0.5408925374754288]</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>-0.000000</td>\n",
       "      <td>[-2951536376908.392]</td>\n",
       "      <td>[-0.7440003973556821]</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>-0.000000</td>\n",
       "      <td>[-2951536376908.5474]</td>\n",
       "      <td>[-0.8650397289256893]</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>[-11159910978512.24]</td>\n",
       "      <td>[0.23480992782501636]</td>\n",
       "      <td>18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>-0.000000</td>\n",
       "      <td>[-11159910978512.305]</td>\n",
       "      <td>[0.14390274776094955]</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>[-11159910978512.605]</td>\n",
       "      <td>[-0.05001887570951939]</td>\n",
       "      <td>17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>-0.000000</td>\n",
       "      <td>[-11159910978512.623]</td>\n",
       "      <td>[-0.05000636659191947]</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>-0.000000</td>\n",
       "      <td>[-11159910978512.627]</td>\n",
       "      <td>[-0.07469735734465875]</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>-0.000000</td>\n",
       "      <td>[-11159910978512.639]</td>\n",
       "      <td>[-0.10030947860620458]</td>\n",
       "      <td>15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>-0.000000</td>\n",
       "      <td>[-11159910978512.662]</td>\n",
       "      <td>[-0.10368059733366085]</td>\n",
       "      <td>16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>0.073134</td>\n",
       "      <td>[-17398699025110.596]</td>\n",
       "      <td>[0.4125975281285337]</td>\n",
       "      <td>21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>-0.000000</td>\n",
       "      <td>[-17398699025110.793]</td>\n",
       "      <td>[0.2252327872696695]</td>\n",
       "      <td>22</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>-0.000000</td>\n",
       "      <td>[-17398699025111.723]</td>\n",
       "      <td>[-0.6378303153982041]</td>\n",
       "      <td>23</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    coef_lasso                coef_lr               coef_ridge  columns\n",
       "20   -0.000000   [1607443908474.2002]    [0.14879929630391564]       20\n",
       "19    0.000000    [1607443908473.824]   [-0.14879929630391275]       19\n",
       "24    0.144632       [0.583740234375]     [0.4465589474930137]       24\n",
       "27   -0.130831        [-0.1298828125]    [-0.1316735240402745]       27\n",
       "26   -0.051002     [-0.1475830078125]    [-0.1480803984324322]       26\n",
       "25    0.555132        [-0.1669921875]   [0.029002243949391965]       25\n",
       "9     0.000000  [-2951536376906.9746]     [0.5405437508370186]        9\n",
       "4     0.000000   [-2951536376907.002]    [0.48799560962999095]        4\n",
       "8     0.000000  [-2951536376907.0605]    [0.45741743996601597]        8\n",
       "5     0.000000  [-2951536376907.1523]    [0.34425680062324465]        5\n",
       "10    0.000000   [-2951536376907.293]    [0.27113993491859273]       10\n",
       "7    -0.000000  [-2951536376907.3867]    [0.09528884692115817]        7\n",
       "6    -0.000000   [-2951536376907.491]  [-0.010332991168896355]        6\n",
       "3    -0.000000   [-2951536376907.543]   [0.001465149725495822]        3\n",
       "11    0.000000  [-2951536376907.6406]   [-0.03784187769581854]       11\n",
       "2    -0.000000   [-2951536376908.164]    [-0.5408925374754288]        2\n",
       "1    -0.000000   [-2951536376908.392]    [-0.7440003973556821]        1\n",
       "0    -0.000000  [-2951536376908.5474]    [-0.8650397289256893]        0\n",
       "18    0.000000   [-11159910978512.24]    [0.23480992782501636]       18\n",
       "12   -0.000000  [-11159910978512.305]    [0.14390274776094955]       12\n",
       "17    0.000000  [-11159910978512.605]   [-0.05001887570951939]       17\n",
       "14   -0.000000  [-11159910978512.623]   [-0.05000636659191947]       14\n",
       "13   -0.000000  [-11159910978512.627]   [-0.07469735734465875]       13\n",
       "15   -0.000000  [-11159910978512.639]   [-0.10030947860620458]       15\n",
       "16   -0.000000  [-11159910978512.662]   [-0.10368059733366085]       16\n",
       "21    0.073134  [-17398699025110.596]     [0.4125975281285337]       21\n",
       "22   -0.000000  [-17398699025110.793]     [0.2252327872696695]       22\n",
       "23   -0.000000  [-17398699025111.723]    [-0.6378303153982041]       23"
      ]
     },
     "execution_count": 347,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mses = np.mean(lasso.mse_path_, axis = 1)\n",
    "plt.plot(np.log10(lasso.alphas_), mses) \n",
    "#plt.plot(np.log10(lasso.alphas_)*np.ones(3), [0.3, 0.4, 1.0])\n",
    "plt.xlabel('log(alpha)')\n",
    "plt.ylabel('mse')\n",
    "plt.show()    \n",
    "            \n",
    "print ('alpha is:', lasso.alpha_)\n",
    "\n",
    "# 看看各特征的权重系数，系数的绝对值大小可视为该特征的重要性\n",
    "fs = pd.DataFrame({\"columns\":list(range(X_train.shape[1])), \"coef_lr\":list((lr.coef_.T)), \"coef_ridge\":list((ridge.coef_.T)), \"coef_lasso\":list((lasso.coef_.T))})\n",
    "fs.sort_values(by=['coef_lr'],ascending=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
